	
	use "$data/raw/WVS_raw.dta", clear
	
	* Gen country

	decode S003, gen(country_gallup)

	* Generate stata_id

	gen stata_id=. 	
	replace stata_id=1 		if country_gallup=="Afghanistan"
	replace stata_id=2	 	if country_gallup=="Albania"
	replace stata_id=3		if country_gallup=="Algeria"
	replace stata_id=4		if country_gallup=="Angola"
	replace stata_id=5		if country_gallup=="Argentina"
	replace stata_id=6		if country_gallup=="Armenia"
	replace stata_id=7		if country_gallup=="Australia"
	replace stata_id=8		if country_gallup=="Austria"
	replace stata_id=9		if country_gallup=="Azerbaijan"
	replace stata_id=10		if country_gallup=="Bahamas, The"
	replace stata_id=11		if country_gallup=="Bahrain"
	replace stata_id=12		if country_gallup=="Bangladesh"
	replace stata_id=13		if country_gallup=="Barbados"
	replace stata_id=14		if country_gallup=="Belarus"
	replace stata_id=15		if country_gallup=="Belgium"
	replace stata_id=16		if country_gallup=="Belize"
	replace stata_id=17		if country_gallup=="Benin"
	replace stata_id=18		if country_gallup=="Bhutan"
	replace stata_id=19		if country_gallup=="Bolivia"
	replace stata_id=21		if country_gallup=="Bosnia and Herzegovina" | country_gallup=="Bosnia Herzegovina" | country_gallup=="Bosnia"
	replace stata_id=22		if country_gallup=="Botswana"
	replace stata_id=23		if country_gallup=="Brazil"
	replace stata_id=24		if country_gallup=="Brunei Darussalam"
	replace stata_id=25		if country_gallup=="Bulgaria"
	replace stata_id=26		if country_gallup=="Burkina Faso"
	replace stata_id=27		if country_gallup=="Burundi"
	replace stata_id=28		if country_gallup=="Cabo Verde"
	replace stata_id=29		if country_gallup=="Cambodia"
	replace stata_id=30		if country_gallup=="Cameroon"
	replace stata_id=31		if country_gallup=="Canada"
	replace stata_id=32		if country_gallup=="Cape Verde"
	replace stata_id=33		if country_gallup=="Central African Republic"
	replace stata_id=34		if country_gallup=="Chad"
	replace stata_id=35		if country_gallup=="Chile"
	replace stata_id=36		if country_gallup=="China"
	replace stata_id=37		if country_gallup=="Colombia"
	replace stata_id=38		if country_gallup=="Comoros"
	replace stata_id=39		if country_gallup=="Congo Brazzaville"
	replace stata_id=40		if country_gallup=="Congo Kinshasa"
	replace stata_id=41		if country_gallup=="Costa Rica"
	replace stata_id=42		if country_gallup=="Croatia"
	replace stata_id=43		if country_gallup=="Cuba"
	replace stata_id=44		if country_gallup=="Cyprus"
	replace stata_id=45		if country_gallup=="Czech Republic" | country_gallup=="Czech Rep."
	replace stata_id=46		if country_gallup=="Denmark"
	replace stata_id=47		if country_gallup=="Djibouti"
	replace stata_id=48		if country_gallup=="Dominican Republic" | country_gallup=="Dominican Rep."
	replace stata_id=49		if country_gallup=="East Timor"
	replace stata_id=50		if country_gallup=="Ecuador"
	replace stata_id=51		if country_gallup=="Egypt"
	replace stata_id=52		if country_gallup=="El Salvador"
	replace stata_id=53		if country_gallup=="Equatorial Guinea"
	replace stata_id=54		if country_gallup=="Eritrea"
	replace stata_id=55		if country_gallup=="Estonia"
	replace stata_id=56		if country_gallup=="Ethiopia"
	replace stata_id=58		if country_gallup=="Fiji"
	replace stata_id=59		if country_gallup=="Finland"
	replace stata_id=60		if country_gallup=="France"
	replace stata_id=61		if country_gallup=="Gabon"
	replace stata_id=62		if country_gallup=="Gambia"
	replace stata_id=63		if country_gallup=="Georgia"
	replace stata_id=64		if country_gallup=="Germany"
	replace stata_id=65		if country_gallup=="Ghana"
	replace stata_id=66		if country_gallup=="Greece"
	replace stata_id=67		if country_gallup=="Guatemala"
	replace stata_id=68		if country_gallup=="Guinea"
	replace stata_id=70		if country_gallup=="Guyana"
	replace stata_id=71		if country_gallup=="Haiti"
	replace stata_id=72		if country_gallup=="Honduras"
	replace stata_id=73		if country_gallup=="Hong Kong"
	replace stata_id=75		if country_gallup=="Hungary"
	replace stata_id=76		if country_gallup=="Iceland"
	replace stata_id=77		if country_gallup=="India"
	replace stata_id=78		if country_gallup=="Indonesia"
	replace stata_id=79		if country_gallup=="Iran"
	replace stata_id=80		if country_gallup=="Iraq"
	replace stata_id=81		if country_gallup=="Ireland"
	replace stata_id=82		if country_gallup=="Israel"
	replace stata_id=83		if country_gallup=="Italy"
	replace stata_id=84		if country_gallup=="Ivory Coast"
	replace stata_id=85		if country_gallup=="Jamaica"
	replace stata_id=86		if country_gallup=="Japan"
	replace stata_id=87		if country_gallup=="Jordan"
	replace stata_id=88		if country_gallup=="Kazakhstan"
	replace stata_id=89		if country_gallup=="Kenya"
	replace stata_id=91		if country_gallup=="Korea North"
	replace stata_id=92		if country_gallup=="Kosovo"
	replace stata_id=93		if country_gallup=="Kuwait"
	replace stata_id=94		if country_gallup=="Kyrgyz Republic"
	replace stata_id=95		if country_gallup=="Kyrgyzstan"
	replace stata_id=96		if country_gallup=="Laos"
	replace stata_id=97		if country_gallup=="Latvia"
	replace stata_id=98		if country_gallup=="Lebanon"
	replace stata_id=99		if country_gallup=="Lesotho"
	replace stata_id=100	if country_gallup=="Liberia"
	replace stata_id=101	if country_gallup=="Libya"
	replace stata_id=102	if country_gallup=="Lithuania"
	replace stata_id=103	if country_gallup=="Luxembourg"
	replace stata_id=104	if country_gallup=="Macao SAR"
	replace stata_id=106	if country_gallup=="Macedonia, FYR" | country_gallup=="Macedonia"
	replace stata_id=107	if country_gallup=="Madagascar"
	replace stata_id=108	if country_gallup=="Malawi"
	replace stata_id=109	if country_gallup=="Malaysia"
	replace stata_id=110	if country_gallup=="Mali"
	replace stata_id=111	if country_gallup=="Malta"
	replace stata_id=112	if country_gallup=="Mauritania"
	replace stata_id=113	if country_gallup=="Mauritius"
	replace stata_id=114	if country_gallup=="Mexico"
	replace stata_id=115	if country_gallup=="Moldova"
	replace stata_id=116	if country_gallup=="Mongolia"
	replace stata_id=117	if country_gallup=="Montenegro"
	replace stata_id=118	if country_gallup=="Morocco"
	replace stata_id=119	if country_gallup=="Mozambique"
	replace stata_id=120	if country_gallup=="Myanmar"
	replace stata_id=122	if country_gallup=="Nagorno Karabakh"
	replace stata_id=123	if country_gallup=="Namibia"
	replace stata_id=124	if country_gallup=="Nepal"
	replace stata_id=125	if country_gallup=="Netherlands"
	replace stata_id=126	if country_gallup=="New Zealand"
	replace stata_id=127	if country_gallup=="Nicaragua"
	replace stata_id=128	if country_gallup=="Niger"
	replace stata_id=129	if country_gallup=="Nigeria"
	replace stata_id=130	if country_gallup=="Northern Cyprus"
	replace stata_id=131	if country_gallup=="Norway"
	replace stata_id=132	if country_gallup=="Oman"
	replace stata_id=133	if country_gallup=="Pakistan"
	replace stata_id=134	if country_gallup=="Palestine"
	replace stata_id=135	if country_gallup=="Panama"
	replace stata_id=136	if country_gallup=="Papua New Guinea"
	replace stata_id=137	if country_gallup=="Paraguay"
	replace stata_id=138	if country_gallup=="Peru"
	replace stata_id=139	if country_gallup=="Philippines"
	replace stata_id=140	if country_gallup=="Poland"
	replace stata_id=141	if country_gallup=="Portugal"
	replace stata_id=142	if country_gallup=="Puerto Rico"
	replace stata_id=143	if country_gallup=="Qatar"
	replace stata_id=144	if country_gallup=="Romania"
	replace stata_id=145	if country_gallup=="Russia"
	replace stata_id=146	if country_gallup=="Rwanda"
	replace stata_id=147	if country_gallup=="San Marino"
	replace stata_id=148	if country_gallup=="Saudi Arabia"
	replace stata_id=149	if country_gallup=="Senegal"
	replace stata_id=150	if country_gallup=="Serbia"
	replace stata_id=151	if country_gallup=="Serbia and Montenegro"
	replace stata_id=152	if country_gallup=="Seychelles"
	replace stata_id=153	if country_gallup=="Sierra Leone"
	replace stata_id=154	if country_gallup=="Singapore"
	replace stata_id=155	if country_gallup=="Slovak Republic" | country_gallup=="Slovakia"
	replace stata_id=157	if country_gallup=="Slovenia"
	replace stata_id=158	if country_gallup=="Solomon Islands"
	replace stata_id=159	if country_gallup=="Somalia"
	replace stata_id=161	if country_gallup=="South Africa"
	replace stata_id=162	if country_gallup=="South Korea"
	replace stata_id=163	if country_gallup=="South Sudan"
	replace stata_id=164	if country_gallup=="Spain"
	replace stata_id=165	if country_gallup=="Sri Lanka"
	replace stata_id=166	if country_gallup=="Sudan"
	replace stata_id=168	if country_gallup=="Suriname"
	replace stata_id=169	if country_gallup=="Swaziland"
	replace stata_id=170	if country_gallup=="Sweden"
	replace stata_id=171	if country_gallup=="Switzerland"
	replace stata_id=172	if country_gallup=="Syria"
	replace stata_id=173	if country_gallup=="São Tomé and Príncipe"
	replace stata_id=174	if country_gallup=="Taiwan"
	replace stata_id=175	if country_gallup=="Taiwan Province of China"
	replace stata_id=176	if country_gallup=="Tajikistan"
	replace stata_id=177	if country_gallup=="Tanzania"
	replace stata_id=178	if country_gallup=="Thailand"
	replace stata_id=179	if country_gallup=="Togo"
	replace stata_id=180	if country_gallup=="Trinidad and Tobago"
	replace stata_id=181	if country_gallup=="Tunisia"
	replace stata_id=182	if country_gallup=="Turkey"
	replace stata_id=183	if country_gallup=="Turkmenistan"
	replace stata_id=184	if country_gallup=="UAE"
	replace stata_id=185	if country_gallup=="Uganda"
	replace stata_id=186	if country_gallup=="Ukraine"
	replace stata_id=187	if country_gallup=="United Arab Emirates"
	replace stata_id=188	if country_gallup=="United Kingdom"
	replace stata_id=189	if country_gallup=="United States"
	replace stata_id=190	if country_gallup=="Uruguay"
	replace stata_id=191	if country_gallup=="Uzbekistan"
	replace stata_id=192	if country_gallup=="Venezuela"
	replace stata_id=193	if country_gallup=="Vietnam"
	replace stata_id=194	if country_gallup=="Yemen"
	replace stata_id=195	if country_gallup=="Zambia"
	replace stata_id=196	if country_gallup=="Zimbabwe"
	replace stata_id=197	if country_gallup=="Maldives"	

	tab country_gallup if stata_id==.

	drop if stata_id==.

	
	ren S020 year
	keep if inrange(year, 1989, 2014)
	
	save "$data/WVS_cleaned.dta", replace